home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Include / FWRRcShp.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  4.4 KB  |  149 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWRRcShp.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWRRCSHP_H
  13. #define FWRRCSHP_H
  14.  
  15. #ifndef FWSHAPE_H
  16. #include "FWShape.h"
  17. #endif
  18.  
  19. #ifndef FWBNDSHP_H
  20. #include "FWBndShp.h"
  21. #endif
  22.  
  23. //==============================================================================
  24. //    •• Forward Declarations
  25. //==============================================================================
  26.  
  27. class FW_CGraphicContext;
  28. class FW_CRoundRectShapeRep;
  29. class FW_CRectShape;
  30. class FW_COvalShape;
  31. class FW_CArcShape;
  32. class FW_CLineShape;
  33. class FW_CRegionShape;
  34.  
  35. //========================================================================================
  36. //    •• CLASS FW_CRoundRectShape
  37. //========================================================================================
  38.  
  39. class FW_CRoundRectShape : public FW_CShape
  40. {
  41. //----------------------------------------------------------------------------------------
  42. //    • Constructors
  43. //
  44. public:
  45.     FW_CRoundRectShape();
  46.     FW_CRoundRectShape(const FW_CRect& rect, const FW_CPoint& ovalSize);
  47.     
  48.     FW_CRoundRectShape(const FW_CRoundRectShape& other);
  49.     FW_CRoundRectShape(FW_CRoundRectShapeRep* rep);
  50.             
  51. //----------------------------------------------------------------------------------------
  52. //    • operators
  53. //
  54. public:
  55.     FW_CRoundRectShape& operator=(const FW_CRoundRectShape& other);
  56.     FW_CRoundRectShape& operator=(FW_CRoundRectShapeRep* other);
  57.         
  58.     FW_CRoundRectShapeRep* operator->() const
  59.                 {return (FW_CRoundRectShapeRep*)GetRep();}
  60.     
  61. //----------------------------------------------------------------------------------------
  62. //    • Conversion
  63. //
  64. public:
  65.     operator FW_CRectShape() const;
  66.     operator FW_COvalShape() const;
  67.     operator FW_CArcShape() const;
  68.     operator FW_CLineShape() const;
  69.     operator FW_CRegionShape() const;
  70.  
  71. //----------------------------------------------------------------------------------------
  72. //    • Static Methods
  73. //
  74. public:
  75.     static void DrawRoundRect(FW_CGraphicContext* graphicContext, 
  76.                                 const FW_CRect& rect,
  77.                                 const FW_CPoint& ovalSize);
  78. };
  79.  
  80. //==============================================================================
  81. //    •• class FW_CRoundRectShapeRep
  82. //==============================================================================
  83.  
  84. class FW_CRoundRectShapeRep : public FW_CBoundedShapeRep
  85. {
  86.     friend class FW_CRoundRectShape;
  87.     
  88. //------------------------------------------------------------------------------
  89. //    • Constructors/Destructors
  90. //
  91. protected:
  92.     FW_CRoundRectShapeRep();
  93.     FW_CRoundRectShapeRep(const FW_CRect& rect, const FW_CPoint& ovalSize);
  94.     
  95.     virtual ~FW_CRoundRectShapeRep();
  96.     
  97. //------------------------------------------------------------------------------
  98. //    • Inherited API
  99. //
  100. public:
  101.     // ----- Hit Testing -----
  102.     virtual FW_HitTestPart HitTest(const FW_CPoint& test) const;
  103.  
  104.     // ----- Rendering -----
  105.     virtual void     Draw(FW_CGraphicContext* gc);
  106.     static void     DrawRoundRect(FW_CGraphicContext* gc,
  107.                                     const FW_CRect& rect,
  108.                                     const FW_CPoint& ovalSize);
  109.  
  110.     // ----- Default shape -----
  111.     virtual void     SetAsDefault() const;
  112.  
  113.     // ----- Stream -----
  114.     virtual void    Flatten(FW_CWritableStream& stream);
  115.     virtual void    Unflatten(FW_CReadableStream& stream);
  116.  
  117. //------------------------------------------------------------------------------
  118. //    • New API
  119. //
  120. public:
  121.     FW_CRoundRectShape    Copy() const;
  122.  
  123.     FW_CPoint            GetOvalSize() const
  124.                             {return fOvalSize;}    
  125.     void                SetOvalSize(const FW_CPoint& ovalSize)
  126.                             {fOvalSize = ovalSize; Changed();}
  127.     
  128. //------------------------------------------------------------------------------
  129. //    • Data Members
  130. //
  131. private:
  132.     FW_CPoint        fOvalSize;
  133. };
  134.  
  135. //==============================================================================
  136. //    •• Inlines
  137. //==============================================================================
  138.  
  139. //------------------------------------------------------------------------------
  140. //    • FW_CRoundRectShape::DrawRoundRect
  141. //------------------------------------------------------------------------------
  142. inline static void FW_CRoundRectShape::DrawRoundRect(FW_CGraphicContext* graphicContext, 
  143.                                                     const FW_CRect& rect,
  144.                                                     const FW_CPoint& ovalSize)
  145. {
  146.     FW_CRoundRectShapeRep::DrawRoundRect(graphicContext, rect, ovalSize);
  147. }
  148.  
  149. #endif